
<? if($total > count($products)): ?>
	<?= $this->fetch("pagination", array(
		"page" => $page,
		"total" => $total,
		"per_page" => PRODUCTS_PER_PAGE,
		"link" => $link,
		"class" => "top"
	)); ?>
<? endif; ?>

<ul id="items" class="clean products-list">
	<? foreach($products as $product): ?>
	<li>
		<a href="/product/show/<?=$product["id"]; ?>/<?= urlize($product["name"]); ?>">
			<span class="image">
				<? if((int)$product["discount"]>0): ?>
				<span class="discount">AKCIJA!</span>
				<? endif; ?>
				<? 
					$pi = $product["image"] ? $product["image"] : $product["images"][0]["src"];
					$image = $pi ? $product["id"] . "/" . $pi : "no-image.jpg"; 
				?>
				<img src="/image/products/<?=$image ?>?w=220&h=220&bg=white" alt="<?=$product["name"] ?>" />
			</span>
			<span class="name"><?=$product["name"] ?></span>
			<span class="price"><?= number_format($product["price"], 2, ",", ".") ?><span class="currency"><?= CURRENCY_LABEL ?></span></span>
		</a>
	</li>
	<? endforeach; ?>
</ul>

<? if($total > count($products)): ?>
	<?= $this->fetch("pagination", array(
		"page" => $page,
		"total" => $total,
		"per_page" => PRODUCTS_PER_PAGE,
		"link" => $link
	)); ?>
<? endif; ?>